/**
 * Created by jiangguoshun on 16/7/2.
 */
$(function() {
	$('.main-content-wrapper').css('top',
			($('.top-header-wrapper').height() - 3));
	// $('a').click(function () {
	// $(this).find('span').css('color','rgb(255,255,255)');
	// });
});

function _HIDE_TOP_SIDEBAR_() {
	$('.top-header-wrapper .sidebar').addClass('hid');
}

function _SHOW_TOP_SIDEBAR_() {
	$('.top-header-wrapper .sidebar').removeClass('hid');
}

$(function() {
	$('.top-header-wrapper .show-top-header-sidebar-a').click(function() {
		_SHOW_TOP_SIDEBAR_();
	});

	$('.top-header-wrapper .sidebar .side-close-btn').click(function() {
		_HIDE_TOP_SIDEBAR_();
	});
	$('.top-header-wrapper .sidebar .left-side').click(function() {
		_HIDE_TOP_SIDEBAR_();
	});

	// 展示用户额外工具栏
	$('.top-header-wrapper .header-main .name-div .user-info')
			.hover(
					function() {
						$(
								'.top-header-wrapper .header-main .name-div .user-info-extral')
								.show();
					},
					function() {
						$(
								'.top-header-wrapper .header-main .name-div .user-info-extral')
								.hide();
					});

	$('.top-header-wrapper .header-main .name-div .user-info-extral').hover(
			function() {
				$(this).show();
			}, function() {
				$(this).hide();
			});

	// 用户额外工具栏 每栏获得鼠标背景变化
	$('.top-header-wrapper .header-main .name-div .user-info-extral ul li a')
			.hover(function() {
				$(this).addClass('cur-active-undertone');
			}, function() {
				$(this).removeClass('cur-active-undertone');
			});

});

/**
 * 统一登出接口
 */
function logout() {
	$.ajax({
		async : false,
		url : baseUrl + "/logout",
		success : function() {
			// var options = {
			// type: SELF_ALERT_TYPES.success,
			// msg: "退出成功",
			// hasClose: true,
			// time: 3000
			// };
			// selfAlert(options);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			// XMLHttpRequest.status
			var msg = "退出异常 " + " " + XMLHttpRequest.statusText;
			var options = {
				type : SELF_ALERT_TYPES.danger,
				msg : msg,
				hasClose : true,
				time : 3000
			};
			selfAlert(options);
		},
		complete : function() {
			window.location.reload();
		}
	});
}

/**
 * 调整底部
 */
function adjustmentFooter() {
	var windowHeight = $(window).height();
	var headerHeight = $('.top-header-wrapper').outerHeight();
	var sectionHeight = $('.main-content-wrapper-split').outerHeight();
	var adjustmentHeight = windowHeight - headerHeight - sectionHeight;

	// console.info("windowHeight=" + windowHeight + " headerHeight="
	// + headerHeight + " sectionHeight=" + sectionHeight
	// + " adjustmentHeight=" + adjustmentHeight);

	if (adjustmentHeight > 0) {
		$('.main-content').outerHeight(
				$('.main-content').outerHeight() + adjustmentHeight);
	}
}
$(function() {
	adjustmentFooter();
});
